package com.ryan.jmh.test;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.util.concurrent.TimeUnit;

/**
 * <pre>
 * User:        Ryan
 * Date:        2018/2/11
 * Email:       liuwei412552703@163.com
 * Version      V1.0
 * Discription:
 *
 *      JMH  基准测试
 */
public class JmhHelloWorld {


    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void measureThroughput() throws InterruptedException {
        TimeUnit.MILLISECONDS.sleep(100);
    }

    @Benchmark
    public void wellHelloThere() {



    }


    public static void main(String[] args) throws RunnerException {

        Options opt = new OptionsBuilder()
                .include(JmhHelloWorld.class.getSimpleName())
                .forks(1)
                .build();

        new Runner(opt).run();

    }
}
